//
//  CardImageView.m
//  Concentration
//
//  Created by Alessi Patrick on 9/14/11.
//  Copyright (c) 2011 __MyCompanyName__. All rights reserved.
//

#import "CardImageView.h"

@implementation CardImageView
@synthesize faceDown,value;

- (id)initWithFrame:(CGRect)aRect value:(int) inValue
{
    self = [super initWithFrame:aRect];
    if (self) {
        self.value = inValue;
        self.faceDown = YES;
        self.userInteractionEnabled = YES;
        
        //self.image = [UIImage imageNamed:@"Card_Back.png"];
        NSBundle *bundle = [NSBundle mainBundle];
            NSString *path = [bundle pathForResource:@"Card_Back" ofType:@"png"];
            self.image = [UIImage imageWithContentsOfFile:path];
            }
    return self;
    
}


-(void) flipCard
{
    if (self.faceDown)
    {
        
        //[NSString stringWithFormat:@"CardFront_%i",self.value];
        
        NSString* frontFileName =[NSString stringWithFormat:@"%daa",self.value];
        
        NSBundle *bundle = [NSBundle mainBundle];
        NSString *path = [bundle pathForResource:frontFileName ofType:@"jpg"];
        self.image  = [UIImage imageWithContentsOfFile:path];
        self.contentMode = UIViewContentModeScaleAspectFill;
        self.clipsToBounds = YES;
        self.faceDown = NO;
    }
    else
    {
        //self.image = [UIImage imageNamed:@"Card_Back.png"];
        
        NSBundle *bundle = [NSBundle mainBundle];
        NSString *path = [bundle pathForResource:@"Card_Back" ofType:@"png"];
        self.image = [UIImage imageWithContentsOfFile:path];
        
        self.faceDown = YES;
    }
}

@end
